package com.jeffse.light.stream.app.function.union;

import com.jeffse.light.stream.app.pojo.AvgTemperature;
import com.jeffse.light.stream.app.pojo.Temperature;
import com.jeffse.light.stream.core.data.context.ProcessContext;
import com.jeffse.light.stream.core.function.base.ProcessFunction;
import com.jeffse.light.stream.core.pojo.OutTag;

public class UnionOutPutProcessFunction extends ProcessFunction<Temperature, AvgTemperature> {
    private OutTag outTag1;
    private OutTag outTag2;
    private OutTag outTag3;


    public UnionOutPutProcessFunction(OutTag outTag1, OutTag outTag2, OutTag outTag3){
        this.outTag1 = outTag1;
        this.outTag2 = outTag2;
        this.outTag3 = outTag3;
    }
    @Override
    public void processElement(ProcessContext context, Temperature value) throws Exception {
        if(value.getCity().equals("郑州")){
            context.collect(value, outTag2);
        }else if(value.getCity().equals("上海")){
            context.collect(value, outTag1);
        }else{
            context.collect(value, outTag3);
        }
    }
}
